package com.esun.util.webviewchromeclient;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.esun.ui.R;
import com.esun.util.log.EDebug;

/**
 * @ClassName: CustomConfirmDialog
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author: Kael gaojian@500wan.com
 * @date: 2012-7-24 上午11:11:04
 * 
 */
public class CustomConfirmDialog extends Dialog {
	private Button mConfirmButton;
	private Button mCancelButton;
	private TextView mTextViewContent;
	private CharSequence mMessage;
	private View.OnClickListener mConfirmListener;
	private View.OnClickListener mCancelListener;

	/**
	 * @param context
	 */
	public CustomConfirmDialog(Context context) {
		super(context, R.style.dialog);
		setContentView(R.layout.dialog_quit);

		mCancelButton = (Button) findViewById(R.id.dialogquit_btn_submit);
		mConfirmButton = (Button) findViewById(R.id.dialogquit_btn_cancel);
		mCancelButton.setText("取消");
		mConfirmButton.setText("确认提交");
		EDebug.o(this, "");
		mTextViewContent = (TextView) findViewById(R.id.dialogquit_tv_msg);
		mCancelButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}

	@Override
	protected void onStart() {
		mTextViewContent.setText(mMessage);
		if (mConfirmListener != null) {
			mConfirmButton.setOnClickListener(mConfirmListener);
		}
		if (mCancelListener != null) {
			mCancelButton.setOnClickListener(mCancelListener);
		}
	}

	public void setMessage(CharSequence message) {
		this.mMessage = message;
	}

	public void setOnConfirmListener(View.OnClickListener l) {
		this.mConfirmListener = l;
	}

	public void setOnCancelListener(View.OnClickListener l) {
		this.mCancelListener = l;
	}

}
